<html>
<head><meta charset="utf-8"><title>unused substs + self ref closure · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/unused.20substs.20.2B.20self.20ref.20closure.html">unused substs + self ref closure</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241695061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/unused%20substs%20%2B%20self%20ref%20closure/near/241695061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/unused.20substs.20.2B.20self.20ref.20closure.html#241695061">(Jun 06 2021 at 14:42)</a>:</h4>
<p>Think this is another case of unused substs in anon consts causing issues <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> <a href="https://github.com/rust-lang/rust/issues/85665">#85665</a></p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(const_generics, const_evaluatable_checked)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">;</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">F</span>: <span class="nb">FnOnce</span><span class="p">(</span><span class="n">Foo</span><span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">),</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="n">_</span>: <span class="nc">F</span><span class="p">)</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">foo</span><span class="p">(</span><span class="o">|</span><span class="n">_</span><span class="o">|</span><span class="w"> </span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<div class="codehilite"><pre><span></span><code>error[E0644]: closure/generator type that references itself
 --&gt; src/main.rs:8:9
  |
8 |     foo(|_| ());
  |         ^^^^^^ cyclic type of infinite size
  |
  = note: closures cannot capture themselves or take themselves as argument;
          this error may be the result of a recent compiler bug-fix,
          see issue #46062 &lt;https://github.com/rust-lang/rust/issues/46062&gt;
          for more information

error: aborting due to previous error
</code></pre></div>



<a name="241695151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/unused%20substs%20%2B%20self%20ref%20closure/near/241695151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/unused.20substs.20.2B.20self.20ref.20closure.html#241695151">(Jun 06 2021 at 14:45)</a>:</h4>
<p>I think we have something like: <code>ConstKind::Unevaluated({ N - 1 }, substs: [F, N])</code> which gives us the cylic type error when we <code>relate_substs</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>